package org.aokey.springdemo3.July.book;

import jakarta.servlet.http.HttpSession;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/user")
public class UserController2 {
    @RequestMapping("/login2")
    public boolean login2(String userName, String password, HttpSession session){
        //参数校验
        //账号和密码是否正确
        //设置Session
        //返回结果
        if(!StringUtils.hasLength(userName)||!StringUtils.hasLength(password)){
            return false;
        }
//        if("lishaobo".equals(userName)&&"1314521".equals(password)){
        if("李少博".equals(userName)&&"lishaobo666".equals(password)){
            session.setAttribute("userName",userName);
            return true;
        }
        return false;
    }
}
